<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <style type="text/css">
        .input-col-m {
            width: 60px;
        }

        .input-col-l {
            width: 80px;
        }

        .input-col-xxl {
            width: 1%;
            text-align: right;
        }

        .col-95 {
            width: 95%;
        }

        .col-5 {
            width: 5%;
        }
    </style>

</ui:define>

<ui:define name="content">
<div style="margin:5px;">
<h:form id="form">
<p:growl id="msgs" showDetail="false" life="1500"/>
<div id="header">
    <p:panel header="#{param.batch=='0'?'个人产品套餐签约数据查询':'机构产品套餐签约数据查询'}">
        <h:panelGrid columns="2" cellspacing="5" columnClasses="col-95,col-5">
            <h:panelGrid columns="4" cellspacing="5">
                <h:outputLabel value="机构名称:"/>
                <h:selectOneMenu id="branchid" style="width:153px;"
                                 value="#{psSalesInfoListAction.vo.branchid}">
                    <f:selectItems value="#{psSalesInfoListAction.branchList}"/>
                </h:selectOneMenu>

                <h:outputLabel value="产品套餐:"/>
                <h:selectOneMenu id="prdsetid" style="width:153px;"
                                 value="#{psSalesInfoListAction.vo.prdsetid}">
                    <f:selectItems value="#{psSalesInfoListAction.prdsetList}"/>
                </h:selectOneMenu>

                <h:outputLabel value="提交状态:"
                               rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='0'}"/>
                <h:selectOneMenu id="commitflag" style="width:153px;"
                                 rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='0'}"
                                 value="#{psSalesInfoListAction.vo.commitflag}">
                    <f:selectItems value="#{psSalesInfoListAction.commitflagList}"/>
                </h:selectOneMenu>
                <h:outputLabel value="检核状态:"
                               rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='0'}"/>
                <h:selectOneMenu id="checkflag" style="width:153px;"
                                 rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='0'}"
                                 value="#{psSalesInfoListAction.vo.checkflag}">
                    <f:selectItems value="#{psSalesInfoListAction.checkflagList}"/>
                </h:selectOneMenu>

                <h:outputLabel value="证件类型:"/>
                <h:selectOneMenu id="certtype" style="width:153px;"
                                 value="#{psSalesInfoListAction.vo.certtype}">
                    <f:selectItems value="#{psSalesInfoListAction.certTypeList}"/>
                </h:selectOneMenu>
                <h:outputLabel value="证件号码:"/>
                <p:inputText id="certno" value="#{psSalesInfoListAction.vo.certno}"/>

                <h:outputLabel value="签约起日:" for="startdate"
                        rendered="#{psSalesInfoListAction.archiveMode=='0'}"/>
                <p:inputText id="startdate" required="true" requiredMessage="日期不能为空。"
                             rendered="#{psSalesInfoListAction.archiveMode=='0'}"
                             value="#{psSalesInfoListAction.startDate}" onclick="WdatePicker()"/>
                <h:outputLabel value="签约止日:" for="enddate"
                        rendered="#{psSalesInfoListAction.archiveMode=='0'}"/>
                <p:inputText id="enddate" required="true" requiredMessage="日期不能为空。"
                             rendered="#{psSalesInfoListAction.archiveMode=='0'}"
                             value="#{psSalesInfoListAction.endDate}" onclick="WdatePicker()"/>

                <h:outputLabel value="考核起始:" for="archivestart"
                        rendered="#{psSalesInfoListAction.archiveMode=='1'}"/>
                <p:inputText id="archivestart" required="true" requiredMessage="日期不能为空。"
                             rendered="#{psSalesInfoListAction.archiveMode=='1'}"
                             value="#{psSalesInfoListAction.archivestart}" onclick="WdatePicker({dateFmt:'yyyy-MM'})"/>
                <h:outputLabel value="考核截止:" for="archiveend"
                        rendered="#{psSalesInfoListAction.archiveMode=='1'}"/>
                <p:inputText id="archiveend" required="true" requiredMessage="日期不能为空。"
                             rendered="#{psSalesInfoListAction.archiveMode=='1'}"
                             value="#{psSalesInfoListAction.archiveend}" onclick="WdatePicker({dateFmt:'yyyy-MM'})"/>

            </h:panelGrid>
            <h:panelGrid>
                <p:commandButton id="qrybtn" style="width:90px;" value="查询"
                                 action="#{psSalesInfoListAction.onQuery}"
                                 update="pdt,msgs">
                </p:commandButton>
                <p:commandButton ajax="false" id="btnExport" value="导出" action="#{psSalesInfoListAction.onPrint}"
                                 rendered="#{psSalesInfoListAction.commitMode=='0'}"
                                 style="width:90px;"/>
                <p:commandButton ajax="false" id="btncommit" value="全部提交"
                                 action="#{psSalesInfoListAction.onCommitAllRecords}"
                                 rendered="#{psSalesInfoListAction.commitMode=='1'}"
                                 style="width:90px;"/>
            </h:panelGrid>
        </h:panelGrid>
    </p:panel>
</div>

<p:ajaxStatus style="height:20px;text-align:center">
    <f:facet name="start">
        <h:graphicImage value="/images/ajaxloadingbar.gif"/>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value=""/>
    </f:facet>
</p:ajaxStatus>

<p:dataTable id="pdt" style="width:100%;"
             dynamic="true" selectionMode="single"
             value="#{psSalesInfoListAction.salesList}" var="record"
             rowKey="#{record.guid}"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
             paginator="true" rows="30" paginatorPosition="bottom"
             rowsPerPageTemplate="100,50,30,10,5"
             selection="#{psSalesInfoListAction.selectedProductSetRecord}"
             rowSelectListener="#{psSalesInfoListAction.onSelectPSRecord}"
             update="prddetail chptdetail msgs"
             onRowSelectComplete="carDialog.show()"
             dblClickSelect="true"
             emptyMessage="数据记录为空...">

    <f:facet name="header">
        <h:outputText value="记录总数：#{psSalesInfoListAction.totalcount} 笔"/>
    </f:facet>

    <p:column style="text-align:center" rendered="#{psSalesInfoListAction.batchInputMode=='1'}">
        <f:facet name="header">
            机构名称
        </f:facet>
        <h:outputText value="#{record.branchname}"/>
    </p:column>

    <p:column style="text-align:center" rendered="#{psSalesInfoListAction.batchInputMode=='1'}">
        <f:facet name="header">
            柜员
        </f:facet>
        <h:outputText value="#{record.tellername}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            产品套餐
        </f:facet>
        <h:outputText value="#{record.prdsetname}"/>
    </p:column>
    <p:column style="text-align:center">
        <f:facet name="header">
            签约日期
        </f:facet>
        <h:outputText value="#{record.txndate}"/>
    </p:column>
    <p:column style="text-align:center">
        <f:facet name="header">
            客户信息
        </f:facet>
        <h:outputText value="#{record.certtype}-#{record.certno}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            状态
        </f:facet>
        <h:outputText
                rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='0'}"
                value="#{record.commitflagname} #{record.checkflagname}"/>
        <h:outputText
                rendered="#{psSalesInfoListAction.archiveMode=='0' and psSalesInfoListAction.commitMode=='1'}"
                value="#{record.commitflagname}"/>
        <h:outputText rendered="#{psSalesInfoListAction.archiveMode=='1'}"
                      value="#{record.archiveflagname}"/>
    </p:column>

    <p:column headerText="操作" style="text-align:center"
              rendered="#{psSalesInfoListAction.deleteMode=='1' or psSalesInfoListAction.commitMode=='1'}">
        <h:commandLink immediate="true" value="删除" rendered="#{psSalesInfoListAction.deleteMode=='1'}"
                       action="#{psSalesInfoListAction.onDeleteRecord}">
            <f:setPropertyActionListener value="#{record}"
                                         target="#{psSalesInfoListAction.selectedProductSetRecord}"/>
        </h:commandLink>
        <h:commandLink immediate="true" value="提交" rendered="#{psSalesInfoListAction.commitMode=='1'}"
                       action="#{psSalesInfoListAction.onCommitOneRecord}">
            <f:setPropertyActionListener value="#{record}"
                                         target="#{psSalesInfoListAction.selectedProductSetRecord}"/>
        </h:commandLink>
    </p:column>
</p:dataTable>

<p:dialog header="产品及相应检核指标详细信息" widgetVar="carDialog" resizable="false"
          width="700" modal="true">

    <h:panelGrid id="prddetail">
        <p:dataTable id="pdt1" style="width:100%;"
                     dynamic="true" paginatorPosition="none"
                     value="#{psSalesInfoListAction.salesprdList}" var="prdrecord"
                     update="prddetail chptdetail  msgs"
                     emptyMessage="产品信息为空...">
            <p:column style="text-align:center;width:60px;">
                <f:facet name="header">
                    产品代码
                </f:facet>
                <h:outputText value="#{prdrecord.prdid}"/>
            </p:column>
            <p:column style="text-align:center;width:80px;">
                <f:facet name="header">
                    产品名称
                </f:facet>
                <h:outputText value="#{prdrecord.prdname}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    本产品最终检核结果
                </f:facet>
                <h:outputText value="#{prdrecord.checkflagname}"/>
            </p:column>
        </p:dataTable>
    </h:panelGrid>
    <p:separator/>
    <h:panelGrid id="chptdetail" style="margin-bottom: 5px;">
        <p:dataTable id="pdt2" style="width:100%;"
                     dynamic="true" paginatorPosition="none"
                     value="#{psSalesInfoListAction.salesprdckptList}" var="ckptrecord"
                     emptyMessage="检核记录为空...">
            <p:column style="text-align:center;width:60px;">
                <f:facet name="header">
                    产品名称
                </f:facet>
                <h:outputText value="#{ckptrecord.prdname}"/>
            </p:column>
            <p:column style="text-align:center;width:80px;">
                <f:facet name="header">
                    检核指标名称
                </f:facet>
                <h:outputText value="#{ckptrecord.ckptprdname}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    检核结果
                </f:facet>
                <h:outputText value="#{ckptrecord.checkflagname}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    检核次数
                </f:facet>
                <h:outputText value="#{ckptrecord.checktimes}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    最后检核日期
                </f:facet>
                <h:outputText value="#{ckptrecord.checkdate}"/>
            </p:column>
            <p:column style="text-align:center">
                <f:facet name="header">
                    检核结果说明
                </f:facet>
                <h:outputText value="#{ckptrecord.checklog}"/>
            </p:column>
        </p:dataTable>
    </h:panelGrid>
</p:dialog>
</h:form>
</div>
</ui:define>

</ui:composition>